We need to have “blank maps” to color in as thematic maps, and optionally spatial data (points, lines) to add. Two sources:

  1. Dowloaded file [focus here].
  2. Provided through an R-package [see other workshop].

Various formats possible: Shapefile, GeoJSON, KML, GPX-tracks, etc.

Recommended: Use st_read from the sf library, as it returns a spatial feature object and is based on GDAL : hard to find a format not covered.

Points of attention:

  • We want sf-objects. Frequently already in the right format, if not convert using st_as_sf().
  • Pay attention to included identifier for merging.
# load general packages used below
library(dplyr)   # tidyverse datamanipulation library
library(sf)      # tidyverse spatial features library
library(janitor) # utility function clean_names()
library(mapview)
library(tmap)
library(here)
raillines <- st_read(here('data/source/census_1851_raillines/1851EngWalesScotRail_Lines.shp')) %>%
  clean_names()
## Reading layer `1851EngWalesScotRail_Lines' from data source `/home/rstudio/projects/historical-maps-r/data/source/census_1851_raillines/1851EngWalesScotRail_Lines.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1431 features and 2 fields
## geometry type:  LINESTRING
## dimension:      XY
## bbox:           xmin: 155368 ymin: 36976.83 xmax: 655241.1 ymax: 805911.3
## epsg (SRID):    NA
## proj4string:    +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs
mapview(raillines)
qtm(raillines)

districts <- st_read(here('data/source/census_1851_districts/1851EngWalesRegistrationDistrict.shp')) %>%
  clean_names()
## Reading layer `1851EngWalesRegistrationDistrict' from data source `/home/rstudio/projects/historical-maps-r/data/source/census_1851_districts/1851EngWalesRegistrationDistrict.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1194 features and 6 fields
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: 87019.07 ymin: 7067.26 xmax: 655747.5 ymax: 657473.5
## epsg (SRID):    NA
## proj4string:    +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs
mapview(districts)
qtm(districts)